#ifndef __TTX_ENGINE_H__
#define __TTX_ENGINE_H__

#include <basic_types.h>
#include "ttx_osd.h"

#define LATIN_0 0
#define LATIN_1 1
#define LATIN_2 2
#define LATIN_3 3
#define LATIN_CYRILLIC 4
#define LATIN_GREEK 6
#define LATIN_ARABIC 8
#define ARABIC_HEBREW 10

#define TTXENG_OFF		0
#define TTXENG_SUBT		1
#define TTXENG_TEXT		2

#define TTX_SUBT_LANG_NUM		11

struct t_ttx_lang 
{
	//UINT8 lang_idx;
	UINT16 pid;
	UINT16 page;
	UINT8 lang[3];
	UINT8 ttx_type;
};

enum ttx_event
{
	TTX_PID_UPDATE = 1,
	TTX_PID_ADD,				// Add for SAT2IP
};

typedef void(*TTX_EVENT_CALLBACK)(enum ttx_event event, UINT32 param);

struct ttx_config_par
{
	UINT8 erase_unknown_packet;
	UINT8 ttx_sub_page;
	UINT8 parse_packet26_enable;
	UINT8 user_fast_text;
	UINT8 no_ttx_descriptor;
	UINT8 sys_sdram_size_2m; //true:2M,false:other
	UINT8 hdtv_support_enable;
	UINT8 *ttx_vscrbuf;
	UINT8 *ttx_pallette;

	UINT8 ttx_cyrillic_1_support;
	UINT8 ttx_cyrillic_2_support;
	UINT8 ttx_cyrillic_3_support;
	UINT8 ttx_greek_support;
	UINT8 ttx_arabic_support;
	UINT8 ttx_hebrew_support;
	UINT8 ttx_cyrillic_g2_support;
	UINT8 ttx_greek_g2_support;
	UINT8 ttx_arabic_g2_support;
	UINT8 ttx_g3_support;

	UINT16  ttx_color_number;

	UINT32  ttx_subpage_addr;

	UINT8 osd_layer_id;

	UINT32* (*get_ttxchar_from_cyrillic_1)(UINT8 charset, UINT8 character, UINT8 i);
	UINT32* (*get_ttxchar_from_cyrillic_2)(UINT8 charset, UINT8 character, UINT8 i);
	UINT32* (*get_ttxchar_from_cyrillic_3)(UINT8 charset, UINT8 character, UINT8 i);
	UINT32* (*get_ttxchar_from_greek)(UINT8 charset, UINT8 character, UINT8 i);
	UINT32* (*get_ttxchar_from_arabic)(UINT8 charset, UINT8 character, UINT8 i);
	UINT32* (*get_ttxchar_from_hebrew)(UINT8 charset, UINT8 character, UINT8 i);
	UINT32* (*get_ttxchar_from_g2)(UINT8 charset, UINT8 character, UINT8 i);
	UINT32* (*get_ttxchar_from_cyrillic_g2)(UINT8 charset, UINT8 character, UINT8 i);
	UINT32* (*get_ttxchar_from_greek_g2)(UINT8 charset, UINT8 character, UINT8 i);
	UINT32* (*get_ttxchar_from_arabic_g2)(UINT8 charset, UINT8 character, UINT8 i);
	UINT32* (*get_ttxchar_from_g3)(UINT8 charset, UINT8 character, UINT8 i);
	void (*ttx_drawchar)(UINT16 x, UINT16 y, UINT16 charset, UINT8 fg_color, UINT8 bg_color,UINT8 double_width,UINT8 double_height, UINT8 character, UINT8 p26_char_set);
	UINT32  (*osd_get_scale_para)(enum TVSystem tvsys,INT32 scr_width);
};//cloud

#ifdef __cplusplus
extern "C"
{
#endif
void  TTXEng_Init(void);
void  TTXEng_Attach(struct ttx_config_par *pconfig_par);

INT32 TTXEng_Open(UINT8 subtitle,UINT16 page_num);
void  TTXEng_Close(void);
void  TTXEng_ShowOnOff(BOOL bOn);
void TTXEng_SendKey(TTX_KEYTYPE key);
void TTXEng_default_g0_set(UINT8 g0_set);

UINT32 TTXEng_GetSubtLang(struct t_ttx_lang** list ,UINT8* num);
UINT8 TTXEng_GetCurSubtLang(void);
INT32 TTXEng_SetSubtLang(UINT8 lang);
UINT32 TTXEng_GetInitLang(struct t_ttx_lang** list ,UINT8* num);
INT32 TTXEng_SetInitLang(UINT8 lang);

INT32 ttx_register(UINT32 monitor_id);
INT32 ttx_unregister(UINT32 monitor_id);

void ttx_set_initpage(BOOL Enable, UINT16 page_id);
void  ttx_enable(BOOL);
void TTXPvr_SetSubtLang(struct t_ttx_lang* list ,UINT8 num);
void TTXPvr_SetInitLang(struct t_ttx_lang* list ,UINT8 num);
void ttx_pvr_enable(BOOL Enable,UINT16 dmx_id);

void ttx_reg_callback(TTX_EVENT_CALLBACK callback);
void ttx_unreg_callback();
BOOL ttx_is_available();
void TTxOSD_SetSize(UINT32 width,UINT32 height);


#ifdef __cplusplus
}
#endif

#endif /*__TTX_ENGINE_H__  */

